<?php
/**
 * nmox/main/classes/Text.class.php
 * 
 * @author David Christian Liedle <david.liedle@gmail.com>
 * @link   http://nmox.org/
 *
 */

class Text {
    
    public $buffer;  // One buffer, AND the final output
    public $buffers; // An array of buffers
    
        protected $baked = FALSE;
    
    ############################################################################
    # Construct:
    #
    
    public function __construct(){
        header('Content-Type: text/plain');
    }
    
    ############################################################################
    # Public Methods:
    #
    
    public function add($buffer_nick){
        // add a buffer by nickname
    }
    
    public function bake(){
        // only needed for buffers[], not buffer
        foreach( $buffers as $key=>$value ){
            $this->buffer .= $this->buffers[$key];
        }
    }
    
    public function burn($which_buffer=FALSE){
        // dump and clear
        if( $which_buffer ){
            echo $buffers[$which_buffer];
        } else {
            echo $buffer;
        }
    }
    
    public function commit(){
        // finished
        if( $this->baked ){
            echo $buffer;
        } else {
            $this->bake();
            echo $buffer;
        }
    }
    
    public function stamp(){
        // does not delete like burn does
    }
    
    ############################################################################
    # Housekeeping:
    #
    
    public function __toString(){
        //
        die( xER('You are supposed to *use* the Text.class.php class, not convert it to a string!') );
    }
    
}
